plotGraphOverTime <- function(yValues, outputFilepath)
{
    # Backup default graphical parameters
    defaultPar <- par(no.readonly=TRUE)

    # Setup format and filepath to save graph to
    png(outputFilepath, width=800, height=300)

    # Plot a graph using the vector data
    plot(yValues, main="CPU Idleness", xlab="Time in Seconds", ylab="% CPU Idle", pch=18, col="red", type="o", lty=1, mgp=c(2, 0.5, 0), xaxp=c(1, length(yValues), length(yValues)-1))

    # Print the summary statistics
    summary(yValues)

    # Compute the min, mean and max values
    minValue <- min(yValues)
    meanValue <- mean(yValues)
    maxValue <- max(yValues)

    # Draw lines on the graph for the min, mean and max
    par(lty=2, col="blue")
    abline(h=minValue, v=0)
    abline(h=meanValue, v=0)
    abline(h=maxValue, v=0)

    # Label min, mean and max lines
    mtext("min", side=4, line=0.2, at=c(minValue), cex=0.9, las=2)
    mtext("mean", side=4, line=0.2, at=c(meanValue), cex=0.9, las=2)
    mtext("max", side=4, line=0.2, at=c(maxValue), cex=0.9, las=2)

    meanValText <- as.character(round(meanValue, digits=2))
    mtext(meanValText, side=2, line=0.2, at=c(meanValue), cex=0.7, las=2)

    # Restore default graphical parameters
    par(defaultPar)

    # Shut down graphical device used by R. This also triggers the graph to be saved to the pre-specified filepath
    dev.off()
}
